class Flake {
    constructor(scene,w, h) {
        //make the graphic
        this.f=scene.add.graphics()
        this.f.fillStyle(0xffffff, 1);
        this.f.fillCircle(0,0, 5);
        //
        this.w=w;
        this.h=h;
        //
        //
        //init properties
        this.y = Phaser.Math.Between(0, h);
        this.reset();
    }
    reset()
    {
    	//re-init properites
        this.x = Phaser.Math.Between(0, this.w);
        //
    	this.drift = Phaser.Math.Between(-1, 1) * (.05 + Math.random() * .1);
        this.fallSpeed = 1 + Math.random() * 10;
        this.f.scaleX = .1 + Math.random();
        this.f.scaleY = this.f.scaleX;
        this.f.alpha = .1 + Math.random();
    }
    move()
    {
        this.x+=this.drift;
    	this.y+=this.fallSpeed;
     
        if (this.y>this.h)
    	{
    		//take back to top
            this.y=-10;
    		this.reset();
        }
        this.f.setPosition(this.x,this.y);
    	if (this.prevFlake)
    	{
    		//move the previous flake
    		this.prevFlake.move();
        }
       
    }
}